import plugin from '../../lib/plugins/plugin.js'
import fs from 'node:fs'

export class battery_info extends plugin {
  constructor () {
    super({
      name: '获取电池信息',
      dsc: '空',
      /** https://oicqjs.github.io/oicq/#events */
      event: 'message',
      priority: 3000,
      rule: [
        {
          /** 命 令 正 则 匹 配  */
          reg: '^#电池信息$',
          /** 执 行 方 法  */
          fnc: 'get_battery_info'
        }
      ]
    })
  }
  
async get_battery_info(e) {
  var capacity_info = fs.readFileSync('/sys/class/power_supply/battery/capacity', 'utf8');
  var temperature_info = fs.readFileSync('/sys/class/thermal/thermal_zone19/temp', 'utf8') / 1000;
  await e.reply(`电量: ${capacity_info}%\n温度: ${temperature_info}`);
}
}